package com.you.bio.fileio;

import com.you.bio.constant.Constants;

import java.io.*;

public class FileIODemo {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = new FileInputStream(new File(Constants.INPUT_FILE_PATH));
        OutputStream outputStream = new FileOutputStream(new File(Constants.OUTPUT_FILE_PATH));
        byte[] buf = new byte[2048];
        int len;
        StringBuffer sb = new StringBuffer();
        while ((len = inputStream.read(buf)) != -1) {
            System.out.print(new String(buf, 0, len)); //打印到控制台
            sb.append(new String(buf, 0, len)); //写入到sb内容中
            outputStream.write(buf, 0, len); //写到输出文件中
        }
        System.out.println("--------------------------------");
        System.out.println(sb.toString());
        System.out.println("---------------开始写文件-----------------");
        Thread.sleep(20000L);
    }
}
